home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Hardware / Mac OS USB DDK / Mac OS USB DDK 1.4.1 / Examples / UniversalModule / UniversalModuleHeader.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-25  |  3.5 KB  |  108 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        UniversalModuleHeader.c
  3.  
  4.     Contains:    Universal Module Header file
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #include <Types.h>
  13. #include <Devices.h>
  14. #include <DriverServices.h>
  15. #include <USB.h>
  16.  
  17.  
  18. #include "UniversalModule.h"
  19. #include "UniversalModuleVersion.h"
  20.  
  21. static     OSStatus     UniversalModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  22. static     OSStatus     UniversalModuleFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  23. static     OSStatus     UniversalInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
  24.  
  25. extern    usbUniversalPBStruct myUniversalPBRecord;
  26.  
  27. //------------------------------------------------------
  28. //
  29. //    This is the driver description structure that the expert looks for first.
  30. //  If it's here, the information within is used to match the driver
  31. //  to the device whose descriptor was passed to the expert.
  32. //    Information in this block is also used by the expert when an
  33. //  entry is created in the Name Registry.
  34. //
  35. //------------------------------------------------------
  36. USBDriverDescription    TheUSBDriverDescription = 
  37. {
  38.     // Signature info
  39.     kTheUSBDriverDescriptionSignature,
  40.     kInitialUSBDriverDescriptor,
  41.     
  42.     // Device Info
  43.     0,                                        // vendor = not device specific
  44.     0,                                        // product = not device specific
  45.     0,                                        // version of product = not device specific
  46.     0,                                        // protocol = not device specific
  47.     
  48.     // Interface Info    (* I don't think this would always be required...*)                
  49.     0,                                        // Configuration Value
  50.     0,                                        // Interface Number
  51.     kUSBHIDInterfaceClass,                    // Interface Class
  52.     kUSBNoInterfaceSubClass,                // Interface SubClass
  53.     kUSBNoInterfaceProtocol,                // Interface Protocol
  54.         
  55.     
  56.     // Driver Info
  57.     "\pUSBHIDUniversalModule",                // Driver name for Name Registry
  58.     kUSBHIDInterfaceClass,                    // Device Class  (from USBDeviceDefines.h)
  59.     kUSBCompositeSubClass,                    // Device Subclass 
  60.     kUniversalHexMajorVers, 
  61.     kUniversalHexMinorVers, 
  62.     kUniversalCurrentRelease, 
  63.     kUniversalReleaseStage,                    // version of driver
  64.     
  65.     // Driver Loading Info
  66.     0                                        // Flags (currently undefined)
  67. };
  68.  
  69. USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
  70. {
  71.     kClassDriverPluginVersion,                // Version of this structure
  72.     0,                                        // Hardware Validation Procedure
  73.     UniversalModuleInitialize,                // Initialization Procedure
  74.     UniversalInterfaceInitialize,            // Interface Initialization Procedure
  75.     UniversalModuleFinalize,                // Finalization Procedure
  76.     0,                                        // Driver Notification Procedure
  77. };
  78.     
  79.  
  80.     
  81. // Initialization function
  82. // Called upon load by Expert
  83. static     OSStatus     UniversalModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
  84. {
  85. #pragma unused (busPowerAvailable)
  86.     DriverEntry(device, pDesc);
  87.     return (OSStatus)noErr;
  88. }
  89.  
  90. // Interface Initialization Initialization function
  91. // Called upon load by Expert
  92. static     OSStatus     UniversalInterfaceInitialize (UInt32 interfaceNum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBInterfaceRef interfaceRef)
  93. {
  94.     InterfaceEntry(interfaceNum, pInterface, pDesc, interfaceRef);
  95.     return (OSStatus)noErr;
  96. }
  97.  
  98.  
  99.  
  100. // Termination function
  101. // Called by Expert when driver is being shut down
  102. static OSStatus UniversalModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
  103. {
  104.     InterfaceExit(theDeviceRef, (USBInterfaceDescriptorPtr) pDesc);    // we are only ever installed as an interface module
  105.     return (OSStatus)noErr;
  106. }
  107.  
  108.